<?php
$title = "OnlineShop - Catalog";
$css = "classify.css";
include_once 'common/top.php';
include_once '../Class/DB.php';
$db=new DB();
?>

<div id="classify">
<?php 
$name=$db->get_parent_types(0);
$i=0;
while(isset($name[$i]))
{
	$classes=$db->get_parent_types($name[$i]["tid"]);
?>
<div class="block">
<table>
	<tr>
		<td class="title">
		</td>
		<td>
		<table>
			<tr>
				<td colspan="3">
					<h4><?php echo $name[$i]["name"];?></h4>
				</td>
			</tr>
		<?php 
		$t=0;
		while(isset($classes[$t]))
		{
		?>
			<tr>
				<td>
					<h5><?php echo $classes[$t]["name"]?></h5>
					<?php 
					$products=$db->get_type_product($classes[$t]["tid"]);
					$j=0;
					while(isset($products[$j]))
					{
					?>
					<a href="item.php?id=<?php echo $products[$j]["pid"];?>"><?php echo $products[$j]["p_name"];?></a>
					<?php 
					$j++;
					}
					?>
				</td>
				<td>
					<h5><?php echo $classes[$t+1]["name"]?></h5>
					<?php 
					$products=$db->get_type_product($classes[$t+1]["tid"]);
					$j=0;
					while(isset($products[$j]))
					{
					?>
					<a href="item.php?id=<?php echo $products[$j]["pid"];?>"><?php echo $products[$j]["p_name"];?></a>
					<?php 
					$j++;
					}
					?>
				</td>
				<td>
					<h5><?php echo $classes[$t+2]["name"]?></h5>
					<?php 
					$products=$db->get_type_product($classes[$t+2]["tid"]);
					$j=0;
					while(isset($products[$j]))
					{
					?>
					<a href="item.php?id=<?php echo $products[$j]["pid"];?>"><?php echo $products[$j]["p_name"];?></a>
					<?php 
					$j++;
					}
					?>
				</td>
			</tr>
			<?php 
			$t=$t+3;//3 in a row
		}
			?>
		</table>
		</td>
	</tr>
</table>
</div>
<?php 
$i++;
}
?>
</div>

<?php
include_once 'common/tail.php';
?>